<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/10/21/0021
 * Time: 15:13
 */

namespace App\Transformers;


use App\Models\Good;
use League\Fractal\TransformerAbstract;

class GoodsinfoTransformer extends TransformerAbstract
{
    protected $availableIncludes = ['user'];

    public function transform(Good $good){
        return [
          'goods_name' => $good->goods_name,
           'img' => $good->img,
            'shop_price' => $good->shop_price,
            'market_price' => $good->market_price
        ];
    }

    public function includeUser(Good $good){

        return $this->collection($good->user,new UsersTransformer(false));
    }
}